﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
  public partial class SearchControl : System.Windows.Forms.UserControl
  {
    public SearchControl()
    {
      InitializeComponent();

      UIActionList actionList = new UIActionList();
      actionList.Add("Search", "Search for text in formulae",
        new ActionExecuteDelegate(Search));
      actionList.Add("Copy to clipboard", "Copy the results of the search to the clipboard",
        new ActionExecuteDelegate(CopyToClipboard));
      uiActionsControl.Actions = actionList;
    }

    private Server server;
    public void LoadServer(Server server)
    {
      this.server = server;
    }

    private string Search()
    {
      resultsGrid.DataSource = server.Search(searchTextBox.Text);
      resultsGrid.AutosizeColumns();
      return "";
    }

    private string CopyToClipboard()
    {
      resultsGrid.CopyToClipboard();
      return null;
    }
  }
}
